#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include "testutils.h"

void embargo_test()
{
  int i, j, pass, choice, coin_bonus, played;
  struct gameState state;

  for(i = 0; i < MAX_ITERATIONS; i++){
    coin_bonus = 0;
    pass = 0;
    init_test_data(&state, 1);

    srand(time(NULL));

    state.deckCount[0] = 50;
    for(j = 0; j < state.deckCount[0]; j++){
      state.deck[0][j] = random_card();
    }
    state.handCount[0] = 5;
    for(j = 0; j < state.handCount[0] - 1; j++){
      state.hand[0][j] = random_card();
    }
    state.hand[0][4] = embargo;

    printf("ITERATION %d\n", i);

    choice = rand() % 27;

    if(cardEffect(state.hand[0][4], choice, -1, -1, &state, choice, &coin_bonus) == -1){
      printf("Failure, card effect not returned successfully\n");
    } else
      pass++;

    if(state.coins != 2)
      printf("Failure, coins not gained\n");
    else
      pass++;

    if(state.embargoTokens[choice] == 1)
      pass++;
    else
      printf("Failure, embargo token not set\n");

    if(state.hand[0][4] == embargo || state.handCount[0] == 5)
      printf("Failure, card not discarded\n");
    else
      pass++;

    if(pass == 4)
      printf("Success, all tests successful\n");
  }
}

int main ()
{
  embargo_test();
  return 0;
}
